using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using MCGameEngine.Physic_Layer;

namespace MCGameEngine.Animations
{
    public class Animation
    {
        AnimationPlayer animationPlayer;
        SkinningData skinningData;
        public BasicObject obj;

        public Animation()
        {

        }

        public void AttachTo(BasicObject obj)
        {
            this.obj = obj;
            
            skinningData = obj.Model.Tag as SkinningData;

            if (skinningData == null)
            {
                return;
            }
            animationPlayer = new AnimationPlayer(skinningData);
        }

        public void StartClip(string movieclip)
        {
            if (skinningData != null)
            {
                AnimationClip clip = skinningData.AnimationClips[movieclip];
                animationPlayer.StartClip(clip);
            }
        }

        public void Update(GameTime gameTime)
        {
            animationPlayer.Update(gameTime.ElapsedGameTime, true, obj.World);
        }

        public Matrix[] GetBones()
        {
            return animationPlayer.GetSkinTransforms();
        }
    }
}
